Skip to content

[BUG]: fix github repository file id escaping#3415

Merged
deiga merged 11 commits into
integrations:mainfrom
F-Secure-web:fix-github_repository_file-id-escaping
Jun 2, 2026
Merged

[BUG]: fix github repository file id escaping#3415
deiga merged 11 commits into
integrations:mainfrom
F-Secure-web:fix-github_repository_file-id-escaping

Conversation

@deiga

@deiga deiga commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Resolves #3335


Before the change?

After the change?

  • Terraform successfully operates on resources when filePath in github_repository_resource contains a colon

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@github-actions github-actions Bot added the Type: Bug Something isn't working as documented label May 10, 2026
@deiga deiga marked this pull request as ready for review May 10, 2026 18:54
@deiga deiga changed the title fix github repository file id escaping [BUG]: fix github repository file id escaping May 10, 2026
@deiga deiga requested a review from stevehipwell May 10, 2026 18:55
@deiga deiga added the vNextPatch These issues and PRs should be included in the next patch release label May 10, 2026

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we tested this doesn't break existing IDs? It looks OK, but worth checking. Also should we add this to the next minor release milestone as we can always cherry pick it into a patch if required?

@deiga deiga removed the vNextPatch These issues and PRs should be included in the next patch release label May 24, 2026
@deiga deiga force-pushed the fix-github_repository_file-id-escaping branch from 65ea3b4 to 2598ebe Compare May 24, 2026 12:34
@deiga deiga requested a review from stevehipwell May 24, 2026 12:35
@deiga

deiga commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

@stevehipwell Thanks for asking, I ran v6.11.0 locally and then tried to run this code: same failure, since it was already the v0 migration that was failing!

@deiga deiga added the vNextPatch These issues and PRs should be included in the next patch release label May 24, 2026
@deiga

deiga commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

I think we should release this as a patch, considering that the changes in v6.11.1 are blocking upgrading for anyone with colons in repository_file resources

@stevehipwell

Copy link
Copy Markdown
Collaborator

@deiga do you want to rebase this and then we can get it merged in. Once it's been merged we can decide if we want to cherry pick it onto a patch branch.

Comment thread examples/dev.tfrc Outdated
Comment thread github/resource_github_repository_file_migration.go Outdated
@deiga deiga force-pushed the fix-github_repository_file-id-escaping branch from 7cb06fa to 8f0bfe8 Compare May 26, 2026 17:42
@deiga deiga requested a review from stevehipwell May 26, 2026 17:43
Comment thread github/resource_github_repository_file_migration.go Outdated
deiga added 9 commits May 30, 2026 14:28
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…capred ID parts

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
- We want to ensure that users never accidentally get `hashicorp/github`
- `~/` failed to expand on macOS

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
@deiga deiga force-pushed the fix-github_repository_file-id-escaping branch from aa309fd to 4ea73fb Compare May 30, 2026 11:29
@deiga deiga requested a review from stevehipwell May 30, 2026 11:29
@deiga

deiga commented May 30, 2026

Copy link
Copy Markdown
Collaborator Author

@stevehipwell Implemented your requested changes and I commented out the unit test to propose this format again, since I needed them to determine that my code changes didn't break anything

stevehipwell
stevehipwell previously approved these changes Jun 1, 2026

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Let's get the dev.tfrc file removed in a separate PR.

Comment thread examples/dev.tfrc
@deiga

deiga commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

@robert-crandall Could you please review this? :)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

These provider review instructions are being used.

This PR fixes a regression introduced in v6.11.1 where github_repository_file rejects file paths containing a literal colon. The provider's buildID(repo, file, branch) call refuses non-final parts that contain the : separator; the fix wraps the file/filePath argument in escapeIDPart(...) everywhere the resource ID is built (create, update, import, and the v0→v1 state migration), and adds a real, executable migration test plus an acceptance test exercising a colon-containing file name. Unrelated edits touch examples/resources/repository_file/example_2.tf, the rendered docs/resources/repository_file.md, and examples/dev.tfrc.

Changes:

  • Escape the file segment with escapeIDPart in all four buildID call sites on the resource and its migration.
  • Re-enable the previously commented-out v0→v1 state-upgrade test, switch it to mustGitHubClient, and add a migrates_with_colon_in_file_path case.
  • Add an acceptance test verifying the resource ID contains the escaped file path and that the file attribute round-trips the literal colon.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
github/resource_github_repository_file.go Wraps file/filePath in escapeIDPart for create, update, and import ID construction.
github/resource_github_repository_file_migration.go Hardens type assertions, escapes filePath when building the migrated ID, tags errors as "state upgrade v0".
github/resource_github_repository_file_migration_test.go Uncomments and updates the upgrade test; adds a colon-in-path case.
github/resource_github_repository_file_test.go New acceptance test asserting ID escaping and file round-trip for a colon-containing path.
examples/resources/repository_file/example_2.tf Replaces autocreate_branch = true with an explicit github_branch resource.
docs/resources/repository_file.md Mirrors the example_2.tf change in generated docs.
examples/dev.tfrc Uses $HOME and adds a direct.exclude for hashicorp/github.

Comment thread github/resource_github_repository_file.go
deiga added 2 commits June 1, 2026 21:27
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
@deiga

deiga commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

@stevehipwell copilot caught a bug, please re-review :)

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@deiga deiga merged commit f494cc6 into integrations:main Jun 2, 2026
10 checks passed
@deiga deiga deleted the fix-github_repository_file-id-escaping branch June 2, 2026 17:46
austenstone pushed a commit to austenstone/terraform-provider-github that referenced this pull request Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working as documented vNextPatch These issues and PRs should be included in the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: github_repository_file rejects valid file paths containing ':' in v6.11.1

4 participants